package edu.cuc.nio.buffer;

import java.nio.IntBuffer;

public class BufferDemo01 {
    public static void main(String[] args) {
        IntBuffer intBuffer = IntBuffer.allocate(10);//分配10个大小的缓冲区
        System.out.println("指针位置"+intBuffer.position()+" 缓冲区容量大小"+intBuffer.capacity()+" 缓冲区界限"+intBuffer.limit());
        int[] temp = {5,7,9};
        intBuffer.put(3);
        intBuffer.put(temp);
        System.out.println("指针位置"+intBuffer.position()+" 缓冲区容量大小"+intBuffer.capacity()+" 缓冲区界限"+intBuffer.limit());
        intBuffer.flip();//重置缓冲区
        System.out.println("指针位置"+intBuffer.position()+" 缓冲区容量大小"+intBuffer.capacity()+" 缓冲区界限"+intBuffer.limit());
        //输出指针
        while (intBuffer.hasRemaining()) {
            System.out.println(intBuffer.get());
        }
    }
}
